package day03;

public class Exercise {
    public static void main(String[] args) {
        //1.运算符的练习
        //(1)算数运算符    +   -   *   /(取商)   %(取余)   ++  --
        System.out.println(9/3);//3
        System.out.println(9%3);//0
        int a11 = 5,b11=5;
        System.out.println(a11++);//5
        System.out.println(++b11);//6


        //(2)关系运算符  >   <   >=  <=  ==  !=
        int a12 = 5,b12=8,c12=13;
        System.out.println(a12<b12);//T
        System.out.println(a12+b12==c12);//T


        //(3) 逻辑运算符     &&(短路与，见假为假)    ||(短路或，见真为真)    !(逻辑非)
        int a13 = 5,b13=10,c13=5;
        System.out.println(a13<b13 && c13<b13);//T && T=T
        System.out.println(b13<a13 && c13<b13);//F && T=F

        System.out.println(b13>a13 || c13<b13);//T || T=T
        System.out.println(b13<a13 || c13<b13);//F || T=T

         boolean b = !(a13<b13);
        System.out.println(b);//F


        //(4)赋值运算符  +=  -=  *=  /=  %=
        int a14 = 5;
        a14 += 10;  //相当于a14=a14+10;
        short b14 =5;
        b14 += 10;//相当于b14 = (int)(b14+10)赋值运算符拥有强制转换的功能，


        //(5)字符串连接
        int age =24;
        String name ="WXY";
        String add = "北京市";
        System.out.println("我的名字是"+name+",我今年"+age+"了,我现在居住在"+add);


        //(6)条件运算符/三目
        // boolean?数1:数2;
        int num =2;
        int flag = num>2?1:-1;
        System.out.println(flag);


        //2.分支结构的练习:if
        double price = 300.0;
        if (price>=200){
            price*= 0.8;
        }
        System.out.println(price);//300.0*0.8=240.0

        //if else
        double score = 95;
        if(score>=0 && score<=100){
            System.out.println("成绩合法");
        }else{
            System.out.println("成绩不合法");
        }

        //if else if elseif else
        double sprice = 800.0;
        if (sprice>=1000){
            sprice*=0.6;
        }else if (sprice>=700){
            sprice*=0.8;
        }else if (sprice>=500){
            sprice*=0.9;
        }else {
            sprice*=1;
        }
        System.out.println(sprice);//800*0.8=640



    }
}
